package cn.xeblog.server.action.specialAc;

import cn.xeblog.commons.entity.User;
import cn.xeblog.commons.entity.react.request.AdminReact;
import lombok.Getter;

/**
 * @author ZhangLei
 * @date 2024/2/21 13:38
 */
@Getter
public enum VoteActionEnum implements VoteActionExecute {

    BAN("禁言") {
        @Override
        public void doAction(User candidate) {
            adminReact(AdminReact.Operate.USER_PERMIT_REMOVE, candidate.getId());
        }
    }, FREE("解除禁言") {
        @Override
        public void doAction(User candidate) {
            adminReact(AdminReact.Operate.USER_PERMIT_ADD, candidate.getId());
        }
    }, Block("拉黑3分钟") {
        @Override
        public void doAction(User candidate) {
            blockReact(candidate);
        }
    },
    ;

    VoteActionEnum(String content) {
        this.content = content;
    }

    private final String content;

    public static VoteActionEnum getByIndex(int index) {
        if (index < 0 || index >= values().length) {
            return null;
        }
        return values()[index];
    }
}
